package ahblue.cn.tanzi.data.source;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import ahblue.cn.tanzi.cache.ACache;
import ahblue.cn.tanzi.jmessage.JMessageManage;
import ahblue.cn.tanzi.jmessage.im.util.ToastUtil;
import ahblue.cn.tanzi.ui.person.LoginActivity;
import ahblue.cn.tanzi.util.ActivityUtils;

/**
 * @author LuoLin
 * @since Create on 2019/1/17.
 */
public class MyHttpReceiver extends BroadcastReceiver {

    public static final String ACTION_OTHER_DEVICE_LOGINED = "android.intent.action.OTHER_DEVICE_LOGINED";

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (ACTION_OTHER_DEVICE_LOGINED.equals(action)) {
            ToastUtil.shortToast(context, "当前账号已在其他设备登录！");
            JMessageManage.quit();
            ACache.get(context).clear();
            ActivityUtils.getInstance().exit();
            LoginActivity.into(context);
        }
    }

}